package com.apes.fn.business.fixedLoss.modle;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * @description: 定损操作记录
 * @author: wsj
 * @time: 2021/3/2 15:29
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = LossQuotationRecord.CONST_TABLE_NAME)
public class LossQuotationRecord extends BaseModel {
    public final  static String CONST_TABLE_NAME = "ser_loss_quotation_record";

    @Id
    @Column(name = "id", nullable = false, length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "定损操作记录",prefix = "DS")
    @Comment("主键")
    private String id;

    @Comment("操作")
    @Column(name = "operate")
    private String operate;

    @Column(name = "remark", length = 1000)
    @Comment("备注")
    private String remark;

    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "operate_date")
    @Comment("操作时间")
    private Date operateDate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "operate_Uid", referencedColumnName = "id")
    @Comment("操作员")
    private PartyRole operateUid;

    @ManyToOne(optional = false)
    @JoinColumn(name = "loss_Quotation_id", referencedColumnName = "id")
    @Comment("定损报价单号")
    private LossQuotation lossQuotation;
}
